package com.paddyi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.paddyi.mapper.RoleResourceMapper;
import com.paddyi.model.RoleResource;
import com.paddyi.service.IRoleResourceService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 角色资源 (RoleResource)
 *
 * @author paddy
 * @since 2019-04-26 04:34:10
 */
@Service(version = "${demo.service.version}")
public class RoleResourceServiceImpl extends ServiceImpl<RoleResourceMapper, RoleResource> implements IRoleResourceService {

    @Autowired
    private RoleResourceMapper roleResourceMapper;

    public boolean saveRoleMenus(List<RoleResource> roleMenus) {
        Long roleId = roleMenus.get(0).getRoleId();
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("role_id",roleId);
        roleResourceMapper.delete(queryWrapper);
        return this.saveBatch(roleMenus);
    }
}
